package server.protocol.processor;

import java.io.IOException;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.ita.project1.viewController.View;

import common.entity.Person;
import server.invoker.ViewInvoker;
import server.resp.send.Resp;

public  class SendProtocolProcessor {
	public  void process(List<Person> ps,OutputStream out){
		
		//return null;
	}
	
	public void process(Resp resp, OutputStream out) throws IOException{
		try {
//			ObjectOutputStream objectOutputStream = new ObjectOutputStream(out);
			
			ViewProtocolProcessor viewProcessor = new ViewProtocolProcessor();
			View view = viewProcessor.process(resp);
			Map<String, Resp> map = new HashMap<String, Resp>();
			map.put("resp", resp);
			view.setMap(map);
			ViewInvoker viewInvoker = new ViewInvoker(view);
			String header = "HTTP/10.0 200 OK\r\n";
			out.write(header.getBytes());
			out.write("\r\n".getBytes());
			out.write(viewInvoker.invoke());
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally {
			out.close();
		}
	}
}
